package com.liqing.movecomment.controller;

import com.github.pagehelper.PageInfo;
import com.liqing.movecomment.annotation.ResponseResult;
import com.liqing.movecomment.entity.Mycollection;
import com.liqing.movecomment.service.MycollectionService;
import com.liqing.movecomment.vo.CollectionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

@ResponseResult
@Api(tags = "mycollection")
@RequestMapping("mycollection")
public class MycollectionController {
    /**
     * 服务对象
     */
    @Resource
    private MycollectionService mycollectionService;

    /**
     * 分页查询
     *
     * @param page 页码
     * @param size 页长
     * @return 查询结果
     */
    @ApiOperation("我的收藏")
    @GetMapping
    public PageInfo<CollectionVo> queryAll(Integer page, Integer size) {
        return this.mycollectionService.queryAll(page, size);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */

    @GetMapping("{id}")
    public CollectionVo queryById(@PathVariable("id") Integer id) {
        return this.mycollectionService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param mycollection 实体
     * @return 新增结果
     */
    @PostMapping
    public Mycollection add(@RequestBody Mycollection mycollection) {
        return this.mycollectionService.insert(mycollection);
    }



    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public Boolean deleteById(Integer id) {
        return this.mycollectionService.deleteById(id);
    }

}

